const app = getApp();
const utils = require('../../utils/utils.js');
const myaudio = wx.createInnerAudioContext();
Page({
    data: {
        password: "",
        used_id: 0
    },
    onLoad: function (options) {
        wx.showLoading({
            title: 'loading...',
            mask: true
        });
        wx.setInnerAudioOption({
            obeyMuteSwitch: false
        });
        myaudio.src = encodeURI("https://www.zjsuichong.com/min/images/line_Tips.mp3");
        myaudio.play();
        let json = JSON.parse(options.data);
        this.setData({
            password: json.password,
            used_id: json.used_id
        });
        wx.hideLoading();
        wx.showModal({
            title: '温馨提示',
            content: "如果输入密码不能充电,请点击【再次获取密码】按钮",
            success(result) {
            }
        })
    },
    // ==================== 跳转到个人用户页面 ==============================
    goToUser() {
        //跳转用户界面
        wx.reLaunch({
            url: '../user/user'
        });
    },
    // ==================== 再次获取密码 ======================================
    againGetPwd() {
        wx.showLoading({
            title: 'loading...',
            mask: true
        });
        let that = this;
        let used_id = that.data.used_id;
        utils.httpRequest('/againGetPwd', {
            used_id: used_id
        }, function (res) {
            wx.hideLoading();
            if (res.code == 1) {
                that.setData({
                    password: res.data.password
                })
            }
        })
    },
    onHide: function () {
        myaudio.pause();
    },
    onUnload: function () {
        myaudio.pause();
    }
})